using UnityEngine;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// Path switch action.
/// </summary>
public enum PathSwitchAction
{
	Automatic,
	GoLeft,
	GoRight
}

/// <summary>
/// Path combination.
/// </summary>
public class PathRoute
{
	public PathRoute ()
	{
		m_candidatePaths = new Dictionary<PathSwitchAction, IPath> ();
	}
	
	public bool AddPathCandidate (PathSwitchAction switchAction, IPath candidate)
	{
		if (m_candidatePaths.ContainsKey (switchAction))
		{
			return false;
		}
		
		m_candidatePaths.Add (switchAction, candidate);
		return true;
	}
	
	public bool RemovePathCandidate (PathSwitchAction switchAction)
	{
		return m_candidatePaths.Remove (switchAction);
	}
	
	public IPath GetCandidate (PathSwitchAction switchAction)
	{
		IPath result = null;
		m_candidatePaths.TryGetValue (switchAction, out result);
		return result;
	}
	
	public IPath inPath
	{
		set 
		{
			m_inPath = value; 
		}
	}
	
	IPath m_inPath;
	IDictionary<PathSwitchAction, IPath> m_candidatePaths;
}

/// <summary>
/// Path joint is used to connect several path at their end-points.
/// When player moves along with a path and reaches a path-joint, 
/// his next path is determined by pre-configuration of this joint.
/// </summary>
public class PathJoint
{
	public PathJoint ()
	{
		m_pathsConnected = new List<PathPair> ();
		m_pathRoutes = new List<PathRoute> ();
	}
	
	public void AddPath (PathPair pathPair)
	{
		m_pathsConnected.Add (pathPair);
	}
	
	public void AddRoute (PathRoute pathRoute)
	{
		m_pathRoutes.Add (pathRoute);
	}
	
	List<PathPair> m_pathsConnected;
	
	List<PathRoute> m_pathRoutes;
}



